//this decides if we pull from the DB or the Cache
//then it sends data to the BrowseSpecificGUI 
//cat version
package edu.unc.comp410.colemangeer.data;

import edu.unc.comp410.colemangeer.demos.ProductsDemo;
import edu.unc.comp410.colemangeer.model.*;
import edu.unc.comp410.colemangeer.ui.*;

import java.io.FileNotFoundException;
import java.util.*;

import org.apache.log4j.Logger;

public class DataChooser2 {
	
	//private static final String machine = "customer1";
	//private static final String DB = "classroom";
	private static Logger log = Logger.getLogger(ProductsDemo.class);
	
	public static void searchAll(){
		if( DB_Cache2.isFull() ){ 
			log.warn( "Cache is full, so use Cache" );
			
			BrowseSpecificGUI2 bsGUI = new BrowseSpecificGUI2( DB_Cache2.getCacheSet());
		}
		else{ //cache is not full
			//TODO: finish this
		}
	} //end of searchAll
	
	public static Set<CatalogItem> searchAllModel(){
		if( DB_Cache2.isFull() ){ 
			log.warn( "Cache is full, so use Cache" );
			
			return DB_Cache2.getCacheSet();
		}
		else{ //cache is not full
			//TODO: finish this
			return null;
		}
	} //end of searchAll
	
	public static void searchByName( String theSearchString ) throws ClassNotFoundException {
		if( DB_Cache2.isFull() ){
			log.warn( "Cache is full, so use Cache" );
			BrowseSpecificGUI2 bsGUI = new BrowseSpecificGUI2( DB_Cache2.getCacheByName( theSearchString ));
		}
		else{ //cache is not full
			//TODO: finish this
		}
	} //end searchByName
	
	public static Set<CatalogItem> searchByNameModel( String theSearchString ) throws ClassNotFoundException {
		if( DB_Cache2.isFull() ){
			 return DB_Cache2.getCacheByName( theSearchString );
		}
		else{ //cache is not full
			return null;
		}
	}
	
}
